package com.quectel.business.pay.handler;

import com.quectel.business.pay.handler.model.CreateBusinessResp;
import com.quectel.business.pay.vo.CreateOrderRequest;
import com.quectel.pay.module.order.dto.PayOrderDto;
import com.quectel.pay.module.order.dto.PayOrderRefundDto;
import com.quectel.util.common.JacksonUtils;
import com.quectel.util.common.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 物业费模拟
 *
 * @author: caolu
 * @email: louis.cao@quectel.com
 * @date: 2023-04-04 09:18:00
 */
@Slf4j
@Component
public class PropertyFeePayHandler implements BasePayHandler {
    @Override
    public Response<CreateBusinessResp> createBusinessOrder(CreateOrderRequest req) {
        CreateBusinessResp createBusinessResp = new CreateBusinessResp();
        createBusinessResp.setTenantId(1L);
        createBusinessResp.setVillageId(502511729863819264L);
        createBusinessResp.setBusinessId(1L);
        createBusinessResp.setProductName("测试一分钱");
        createBusinessResp.setOriginalPrice(new BigDecimal("0.01"));
        createBusinessResp.setSpecialPrice(new BigDecimal("0.01"));
        createBusinessResp.setTtl(null);
        return Response.<CreateBusinessResp>ok().wrap(createBusinessResp);
    }

    @Override
    public Response<Object> createOrderSuccessNotify(PayOrderDto notifyOrder) {
        log.info("createOrderSuccessNotify:{}", JacksonUtils.toJsonString(notifyOrder));
        return Response.ok();
    }

    @Override
    public Response<Object> createOrderFailedNotify(CreateOrderRequest req) {
        log.info("createOrderFailedNotify:{}", JacksonUtils.toJsonString(req));
        return Response.ok();
    }

    @Override
    public Response<Object> cancelOrder(PayOrderDto cancelOrder) {
        return null;
    }

    @Override
    public Response<Object> paySuccessNotify(PayOrderDto order) {
        log.info("paySuccessNotify:{}", JacksonUtils.toJsonString(order));
        return Response.ok();
    }

    @Override
    public Response<Object> refundPreCheck(PayOrderDto payOrderDto, BigDecimal refundAmount) {
        return Response.ok();
    }

    @Override
    public Response<Object> refundSuccessNotify(PayOrderRefundDto refundOrder) {
        return Response.ok();
    }
}
